﻿@model Himall.Web.Areas.SellerAdmin.Models.ShopFreightModel

<script src="~/Scripts/autoNumeric.js"></script>
<div class="container">
    <ul class="nav nav-tabs-custom clearfix">
        <strong>运费设置</strong>
        <li class="active"><a>运费设置</a></li>
    </ul>
    <form class="form-horizontal" role="form">
        <div class="form-group" style="display:none;">
            <label for="" class="col-sm-2 control-label">店铺运费：</label>
            <div class="col-sm-2">
                <input type="text" id="freightInput" class="auto form-control input-sm" name="freight" value="@Model.Freight.ToString("F2")" data-d-group="0" data-a-sign="¥ ">
            </div>
        </div>
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">满额免运费：</label>
            <div class="col-sm-2">
                <input type="text" class="auto form-control input-sm" name="freeFreight" value="@Model.FreeFreight.ToString("F2")" data-d-group="0" data-a-sign="¥ ">
                &nbsp;0表示不启用此功能
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="btn btn-primary">保 存</button>
            </div>
        </div>
    </form>
</div>
<script>
    $(function () {
	$("#freightInput").focus();
        $('button').click(function () {
            var freight = $('input[name="freight"]').autoNumeric('get');
            var freeFreight = $('input[name="freeFreight"]').autoNumeric('get');
            if (freeFreight.length<1)
            {
                alert("请输入数字");
                return;
            }
            if (freeFreight < 0)
            {
                alert("请不要输入小于0的数字");
                return;
            }
            var loading = showLoading();

            $.post('SaveFreightSetting', { freight: freight, freeFreight: freeFreight }, function (result) {
                loading.close();
                if (result.success)
                    $.dialog.succeedTips('保存成功!');
                else
                    $.dialog.errorTips('保存失败!' + result.msg);

            });
        });
        $('.auto').autoNumeric('init');
    })
</script>